﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace DScheme.DancerClasses
{
    enum DancerSex { D, K };

    struct PointD
    {
        public double X;
        public double Y;
        public PointD(double x, double y)
        {
            X = x;
            Y = y;
        }

        public static implicit operator PointD(Point p)
        {
            return new PointD(p.X, p.Y);
        }

        public override string ToString()
        {
            return string.Format("{0}:{1}", Math.Round(X, 2), Math.Round(Y, 2));
        }
    }

    class Dancer
    {
        public DancerSex Sex;
        public int Num;
        /// <summary>позиция в поинтах</summary>
        public PointD Pos;
        /// <summary>позиция в целых поинтах</summary>
        public Point PosP { get { return new Point((int)Math.Round(Pos.X), (int)Math.Round(Pos.Y)); } }
        /// <summary>положение танцора вокруг оси (град). 0 - смотрит вверх</summary>
        public double Angle = 0;

        public DancerHand RightHand = new DancerHand();
        public DancerHand LeftHand = new DancerHand();

        public List<DancerAction> al = new List<DancerAction>();

        /// <summary>все действия выполнены</summary>
        public bool DoneAll
        {
            get
            {
                return !al.Exists(a => (a.State != DancerActionStates.Done));
            }
        }

        public Dancer(DancerSex sex, int num, Point pos)
        {
            Sex = sex;
            Pos = pos;
            Num = num;
        }

        /// <summary>выполнение действий</summary>
        public void ExecuteActions(double actTimeS)
        {
            foreach (DancerAction moveAction in al)
            {
                if (moveAction.State == DancerActionStates.Done) continue;
                moveAction.Execute(actTimeS);
            }
        }

    }

    class DancerHand
    {
        /// <summary>положение используемой руки</summary>
        public PointD Pos;
        /// <summary>на текущий момент рука ипользуется</summary>
        public bool IsUse = false;
    }
}
